<div class="heading">
    <div class="left_heading"></div>
                                
    <div class="content_heading">
        <h3>Quản lý tin tức</h3>
    </div>
                                
    <div class="right_heading"></div>
</div><!-- End .heading -->

<div class="main_content">
    <div class="table_form">
        <form class="search_form" name="search_form" action="news/search" method="get">
        Tìm kiếm: 
        <input class="input" type="text" name="keyword" value="<?php echo $this->searchValue; ?>" />
        <input class="button" type="submit" name="search" value="Tìm kiếm" />
        <span class="msg"><?php echo $this->errorSearch; ?></span>
        </form>
        
        <form class="list_cat_form" action="" method="post">
        <div style="float: right;">
        	<p id="add_form">Số lượng: <span class="msg"><?php echo $this->total; ?></span> Tin tức</p>
	        <?php echo $this->formSubmit('add', 'Thêm mới', array('class' => 'button', 'id' => 'add_form')); ?>
            <?php echo $this->formSubmit('refresh', 'Làm mới', array('class' => 'button', 'id' => 'add_form')); ?>
	        <?php echo $this->formSubmit('delete', 'Xóa', array('class' => 'button', 'id' => 'del_form', 'onclick' => 'return remove_alert()')); ?>
        </div>                   
        <table class="table_style">
            <tr class="head_table">
                <td width="350px">Tiêu đề</td>
                <td width="350px">Ảnh</td>
                <td width="350px">Nội dung</td>
                <td width="350px">Ngày tạo</td>
                <td width="350px">Trạng thái</td>
                <td class="tools">&nbsp;</td>
                <td class="tools">&nbsp;</td>
                <td class="tools"><?php echo $this->formCheckbox('check_all', null, array('id' => 'check_all', 'onClick' => 'checkAll()')); ?></td>
            </tr>
            <?php
                if(count($this->data) > 0) :
                foreach($this->data as $value) :
                $sql_date = strtotime($value['create_date']);
                $create_date = date('d/m/Y H:i:s', $sql_date);
            ?>
            <tr class="records">
                <td>   
                    <div style="width: 200px;">
                        <?php echo $value['news_title']; ?></td>
                    </div>
                <td ><center><img style="width: 110px;height: 110px;"src="<?php echo $this->baseUrl().'/public/files/news/'.$value['news_image'] ;?>" /></center></td>
                <td >
                   <div style="width: 250px;text-align: justify;">
                       <?php  
                            $news = new Admin_Model_News();
                            $new_plaintext = $value['news_plaintext'];
                            $strleng = 250;
                            echo $show = $news->TruncateString($new_plaintext,$strleng,$charset="UTF-8");
                       ?>   
                   </div>                 
                </td>
                <td><?php echo $create_date; ?></td>
                <td >
                    <div style="text-align: center;">
                        <?php
                            if($value['status'] == '1' )
                            {
                                echo 'Hiển thị'; 
                            }
                            else
                            {
                                echo 'Ẩn'; 
                            }
                        ?>
                    </div>
                </td>
                <td><a class="edit" title="Sửa" href="<?php echo $this->baseUrl('/admin/news/edit?news_id=' . $value['news_id']); ?>"></a></td>
                <td><a class="remove" title="Xóa" onclick="return remove_alert()" href="<?php echo $this->baseUrl('/admin/news/delete?news_id=' . $value['news_id']); ?>"></a></td>
                <td><?php echo $this->formCheckbox('check[]', $value['news_id']); ?></td>
            </tr>
            <?php 
                endforeach;
                else :
            ?>
            <tr class="records">
            	<td colspan="8">Hiện không có tin nào được tìm thấy</td>
            </tr>
            <?php endif; ?>
        </table>
        </form>
    </div>
    
    <div class="pagination">
        <?php echo $this->paginationControl($this->data, 'Sliding', 'news/pagination.phtml'); ?>
    </div>
</div><!-- End .main_content -->  